﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using litsdk;

namespace litssh
{
    internal partial class SSHCmdActivityUI : litsdk.ILitUI
    {
        public SSHCmdActivityUI()
        {
            InitializeComponent();
            this.ivHost.ShowVarName(true, false, true, this.tbHost);
            this.ivPort.ShowVarName(true, false, true, this.tbPort);
            this.ivUserName.ShowVarName(true, false, true, this.tbUserName);
            this.ivPassword.ShowVarName(true, false, true, this.tbPassword);
            this.ivCmdStr.ShowVarName(true, false, true, this.tbCmdStr);
            this.svSaveVarRes.ShowVarName(true, false, false);

            this.SaveActivity = () =>
            {
                ca.Host = this.tbHost.Text;
                ca.Port = this.tbPort.Text;
                ca.UserName = this.tbUserName.Text;
                ca.Password = this.tbPassword.Text;
                ca.CmdStr = this.tbCmdStr.Text;
                ca.SaveVarName = this.svSaveVarRes.VarName;
                ca.Name = this.tbActivityName.Text;
            };
        }

        public override string ActivityType => "litssh.SSHCmdActivity";
        SSHCmdActivity ca = null;
        public override void SetActivity(Activity activity)
        {
            ca = activity as SSHCmdActivity;
            this.tbHost.Text = ca.Host;
            this.tbPort.Text = ca.Port;
            this.tbUserName.Text = ca.UserName;
            this.tbPassword.Text = ca.Password;
            this.tbCmdStr.Text = ca.CmdStr;
            this.svSaveVarRes.VarName = ca.SaveVarName;
            this.tbActivityName.Text = ca.Name;
        }
    }
}
